home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 027a / ntxmeter.zip / NTXMETER.ONG < prev    next >
Text File  |  1989-11-27  |  3KB  |  86 lines

  1. *--------------------------------------------------------------------
  2. * program : ntxmeter.ong
  3. * creator : bernard.ong
  4. * created : 11-24-89
  5. * updated : 11-25-89 -> predetermine last record numeric length
  6. *         : 11-27-89 -> speed improvement by taking off macro
  7. * comment : this is a full working UDF that can be implemented in
  8. *           your boilerplate library.
  9. *--------------------------------------------------------------------
  10. *
  11. * what is this about ?
  12. *     
  13. *     this is a short UDF that puts up a moving meter bar on the 
  14. *     screen as you perform an INDEX ON command. it also im-
  15. *     plements a real time numeric counter for the records pro-
  16. *     cessed. you can modify the UDF to just use a numeric counter
  17. *     or just the moving bar meter if you so desire...
  18. *
  19. * why did i do this ? (advantage is relative)
  20. *
  21. *     Zen and aesthetics. some folks want an indication of how far
  22. *     an indexing routine is from being done.  personally, i think
  23. *     it relieves the 'indexing stress' some of us go through. 
  24. *
  25. * disadvantage
  26. *   
  27. *     it's not in assembler or c, so it's real slow. it increases
  28. *     your index time by approximately 2.3 times. here are some figures
  29. *     on indexing a 4191-record database on a 30 wide character field:
  30. *           
  31. *         straight indexing                     22 seconds
  32. *         indexing with numeric counter only    41 seconds
  33. *         indexing with moving meter bar only   43 seconds
  34. *         indexing with full blown UDF          52 seconds
  35. *           
  36. * some comments
  37. *
  38. *     i haven't tested this UDF on real large databases. if you find
  39. *     a way to speed up the UDF or ran some test results different
  40. *     from the above, you could post me a message. in the meantime,
  41. *     hope this routine would be useful to anybody who needs it. 
  42. *     look at sample.prg to see how UDF is being implemented.
  43. *
  44. * acknowledgement
  45. *     thanks to GARY DOUGLAS PINDER for his numeric counter routine
  46. *     for indexing. his routine is arced under file ODOMET.ARC.
  47. *
  48. * BERNARD ONG (73667,1516)
  49. *
  50. *--------------------------------------------------------------------
  51. function ntxmeter
  52. parameters keyer,_meterline
  53. private keyer,_meterline,_percent
  54.  
  55. if .not. eof()
  56.   if (empty(indexkey(indexord()))) .and. (empty(indexkey(1)))
  57.  
  58.     * numeric counter number
  59.     @ _meterline-02,30 say str(recno(),len(ltrim(str(lastrec()))))
  60.  
  61.     * moving meter bar routine
  62.     _percent = recno()/lastrec()*60
  63.     @ _meterline,10 say replicate('█',_percent)
  64.  
  65.   endif
  66. endif
  67. return keyer
  68. *
  69. *--------------------------------------------------------------------
  70. function meterbox
  71. parameters boxline
  72. private boxline,length
  73.  
  74. * draw meter borders and labels
  75. @ boxline-01,09 to boxline+1,70
  76. @ boxline+02,09 say '0%'
  77. @ boxline+02,67 say '100%'
  78. @ boxline+00,10 say replicate('░',60)
  79. length = len(ltrim(str(lastrec())))
  80. @ boxline-02,10 say 'Records Completed : '+space(length)+'/'+ltrim(str(lastrec()))
  81. return ''
  82. *
  83. *
  84. * eof: ntxmeter.ong
  85.